package org.java.order.exception;

import org.java.order.enums.OrderEnum;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author WHQ
 * @version 1.0
 * @date 2022-3-20 0020 下午 2:50
 */
@ControllerAdvice
public class OrderExceptionHandler {
    @ExceptionHandler(OrderException.class)
    public ResponseEntity<ExceptionVo> handleException(OrderException orderException){
        System.out.println("进入订单异常管理");
        return ResponseEntity.status(orderException.getOrderEnum().getCode()).body(new ExceptionVo(orderException.getOrderEnum()));
    }
}
